Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@appolo/http

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appolo/http

appolo http module

  • 8.1.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
147
decreased by-19.23%
Maintainers
2
Weekly downloads
 
Created
Source

Http Service module for appolo build with axios

Installation

npm i @appolo/http

in config/modules/all.ts

Options

keyDescriptionTypeDefault
idhttpService injection idstringhttpService

any option from Request Config can be added and will be added to all request.

import {HttpModule} from '@appolo/http';

export = async function (app: App) {
   await app.module(new HttpModule({baseURL:"https://some-domain.com/api/",retry:2}));
}

Usage

import {define, singleton,inject} from 'appolo'
import {publisher} from "@appolo/http";

@define()
@singleton()
export class SomeManager {

    @inject httpService:HttpService

    async getUserId(): Promise<string> {

        let result = await this.httpService.request<{userId:string}>({
            url:"http://someurl"
            method:"post"
            timeout:1000
            retry:3
        })

        return result.data.userId
    }
}

Request Config

keyDescriptionTypeDefault
url`request urlstring``
methodis the request method to be used when making the requeststringget
baseURLbaseURL will be prepended to url unless url is absolutestring``
headerscustom headersobject{}
paramsare the URL parameters to be sent with the requestobject{}
datathe data to be sent as the request bodyobject{}
timeoutspecifies the number of milliseconds before the request times outnumber0
withCredentialsindicates whether or not cross-site Access-Control requestsbooleanfalse
authindicates that HTTP Basic auth should be used, and supplies credentialsobject{}
authDigestindicates that HTTP Digest Auth should be used, and supplies credentialsobject{}
responseTypeindicates the type of data that the server will respond withstringjson
responseEncodingindicates encoding to use for decoding responsesstringutf8
maxRedirectsdefines the maximum number of redirects to follow in node.jsnumber5
retryretry times on requests that return a response (500, etc) before giving upnumber0
noResponseRetriesetry times on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc)number0
retryDelayMilliseconds to delay at firstnumber100

Keywords

FAQs

Package last updated on 18 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc